home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Griffith 0.9.8 / griffith-0.9.8-win32.exe / {app} / lib / plugins / movie / PluginMovieFilmDb.py < prev    next >
Text File  |  2008-11-17  |  5KB  |  145 lines

  1. # -*- coding: UTF-8 -*-
  2.  
  3. __revision__ = '$Id: PluginMovieFilmDb.py 1040 2008-11-15 21:13:49Z mikej06 $'
  4.  
  5. # Copyright (c) 2007 Michael Jahn
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. # GNU Library General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
  20.  
  21. # You may use and distribute this software under the terms of the
  22. # GNU General Public License, version 2 or later
  23.  
  24. import gutils
  25. import movie
  26. import string
  27.  
  28. plugin_name        = 'FilmDb.de'
  29. plugin_description    = 'FILMDB.DE'
  30. plugin_url        = 'www.filmdb.de'
  31. plugin_language        = _('German')
  32. plugin_author        = 'Michael Jahn'
  33. plugin_author_email    = '<mikej06@hotmail.com>'
  34. plugin_version        = '1.0'
  35.  
  36. class Plugin(movie.Movie):
  37.     def __init__(self, id):
  38.         self.encode='iso-8859-1'
  39.         self.movie_id = id
  40.         self.url = "http://www.filmdb.de/filmanzeige.php?alle=1&filmid=" + self.movie_id
  41.  
  42.     def initialize(self):
  43.         self.tmp_page = gutils.trim(self.page, "<h1>Filmdatenbank - ", "Kommentare</a>")
  44.     
  45.     def get_image(self):
  46.         self.image_url = gutils.trim(self.tmp_page, '<td background="', '"');
  47.  
  48.     def get_o_title(self):
  49.         self.o_title = gutils.trim(self.page, '<h1>Filmdatenbank - ', '</h1>')
  50.  
  51.     def get_title(self):
  52.         self.title = gutils.trim(self.page, '<h1>Filmdatenbank - ', '</h1>')
  53.  
  54.     def get_director(self):
  55.         self.director = gutils.after(gutils.trim(self.tmp_page, 'regisseursuche.php', '</a>'), '>')
  56.  
  57.     def get_plot(self):
  58.         self.plot = gutils.trim(self.tmp_page, '>Inhalt</strong>', '<td width="150" valign="top">')
  59.         self.plot = self.plot.replace('\t', '')
  60.         self.plot = self.plot.replace('\n', '')
  61.         self.plot = self.plot.replace('ä', '"')
  62.         self.plot = self.plot.replace('ô', '"')
  63.  
  64.     def get_year(self):
  65.         elements = string.split(self.tmp_page, 'landjahrsuche.php')
  66.         self.year = gutils.trim(elements[2], '>', '</a>') + '\n'
  67.  
  68.     def get_runtime(self):
  69.         self.runtime = ""
  70.         tmp = gutils.trim(self.tmp_page, '</a>  û ', ' Stunden')
  71.         if tmp <> '':
  72.             elements = string.split(tmp, ':')
  73.             try:
  74.                 hours = int(elements[0])
  75.                 mins = int(elements[1])
  76.                 self.runtime = str(hours * 60 + mins)
  77.             except:
  78.                 self.runtime = ""
  79.  
  80.     def get_genre(self):
  81.         self.genre = gutils.after(gutils.trim(self.tmp_page, 'genresuche.php', '</a>'), '>')
  82.  
  83.     def get_cast(self):
  84.         self.cast = ""
  85.         elements = string.split(self.tmp_page, 'schauspielersuche.php')
  86.         elements[0] = ''
  87.         for element in elements:
  88.             if element <> '':
  89.                 self.cast = self.cast + gutils.trim(element, '>', '</a>') + '\n'
  90.  
  91.     def get_classification(self):
  92.         self.classification = ""
  93.  
  94.     def get_studio(self):
  95.         self.studio = ""
  96.  
  97.     def get_o_site(self):
  98.         self.o_site = ""
  99.  
  100.     def get_site(self):
  101.         self.site = "http://www.filmdb.de/filmanzeige.php?filmid=" + self.movie_id
  102.  
  103.     def get_trailer(self):
  104.         self.trailer = ""
  105.  
  106.     def get_country(self):
  107.         elements = string.split(self.tmp_page, 'landjahrsuche.php')
  108.         self.country = gutils.trim(elements[1], '>', '</a>') + '\n'
  109.  
  110.     def get_rating(self):
  111.         self.rating = gutils.trim(self.tmp_page, 'Unsere User haben diesen Film mit ', ' bewertet.')
  112.         self.rating = self.rating.replace('%', '')
  113.         self.rating = gutils.strip_tags(self.rating)
  114.         elements = self.rating.split('.')
  115.         try:
  116.             tmprating = int(elements[0])
  117.             self.rating = str(tmprating / 10)
  118.         except:
  119.             self.rating = '0'
  120.  
  121.     def get_notes(self):
  122.         self.notes = ""
  123.  
  124. class SearchPlugin(movie.SearchMovie):
  125.  
  126.     def __init__(self):
  127.         self.original_url_search   = "http://www.filmdb.de/globalsuche.php?name="
  128.         self.translated_url_search = "http://www.filmdb.de/globalsuche.php?name="
  129.         self.encode='iso-8859-1'
  130.  
  131.     def search(self,parent_window):
  132.         self.open_search(parent_window)
  133.         return gutils.trim(self.page, "<span class=font_normal>", "<table width=590")
  134.  
  135.     def get_searches(self):
  136.         elements = string.split(self.page, "<!--")
  137.         elements[0] = ''
  138.         for element in elements:
  139.             if element <> '':
  140.                 self.ids.append(gutils.trim(element, "filmid=", ">"))
  141.                 self.titles.append(gutils.trim(
  142.                     gutils.after(element, "filmid="), ">", "<") + " - " +
  143.                     gutils.trim(gutils.after(element, "</a>"), "<td>", "</td>") + " - " +
  144.                     gutils.trim(gutils.after(gutils.after(element, "<td>"), "<td>"), "<td>", "</td>"))
  145.